home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / LANG / BOB2 / BOB2_1 / !ArmBob / progs / Apply < prev    next >
Text File  |  1994-12-12  |  349b  |  21 lines

  1. /* Example Apply */
  2. /* functions and vectors can be arguments or components */
  3.  
  4. apply(pair)
  5. {
  6.  return pair[function](pair[argument]);
  7. }
  8.  
  9. f(x)               // f takes functions as arguments
  10. { return x(0); }  
  11.  
  12. g(x)
  13. { return (100+x); }
  14.  
  15. main()
  16. {
  17.  enum { function, argument };
  18.  x = vector { f; g; };  // a vector of functions
  19.  print(apply(x),"\n");
  20. }
  21.